<?php
/*
    Authors and license
*/

include_once(dirname(__FILE__).'/../../libraries/security.php');
include_once(dirname(__FILE__).'/message_sql.php');

echo '<div id="post">';

if(isset($_SESSION['logged'])) // user logged in?
{
	$id = $_SESSION['id']; // grab user id to sql querry
	
	echo '<div id="control">';
	echo '<a href="?mod=message&action=inbox" id="messages">'.$lang_message_inbox.'</a>';
	echo '<a href="?mod=message&action=outbox" id="messages">'.$lang_message_outbox.'</a>';
	echo '<a href="?mod=message&action=create" id="messages">'.$lang_message_create.'</a>';
	echo '</div>';
	
	if(isset($_GET['action'])){
		if($_GET['action']=='outbox') {
			include_once(dirname(__FILE__).'/outbox.php'); // sent mesages = outbox
		}
		else if($_GET['action']=='create') {
			include_once(dirname(__FILE__).'/create.php'); // creating new message
		}
		else if($_GET['action']=='view') {
			include_once(dirname(__FILE__).'/view.php'); // wieving message &message=...
		}		
		else  { //($_GET['action']=='inbox')
			include_once(dirname(__FILE__).'/inbox.php'); // default is inbox
		}
	}	
	else {
		include_once(dirname(__FILE__).'/inbox.php'); // default is inbox
	}	
}

echo '</div>';
//  if user is not logged in nothing realy should be done. Just no efect.
?>